<template>
  <div>
    <FilterTable ref="basetable" :height="250" selectionType="single" :columns="columns" :datakey="'rows'" :onColumnsChange="columns => (this.columns = columns)"></FilterTable>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'center'
      }"
    >
      <el-button size="small" type="primary" @click="closeDialog">返回</el-button>
    </div>
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import { queryHistory } from '@/api/customerRepair/customerCare/insuranceDueRemind/index';

export default {
  name: 'xkhistoryquery',
  mixins: [dictionary],
  props: ['VIN'],
  data() {
    this.BaseTable = null;
    return {
      columns: this.createTable()
    };
  },
  mounted() {
    this.BaseTable = this.$refs.basetable.$refs.pageTable;
    this.query();
  },
  methods: {
    createTable() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '险种',
          dataIndex: 'INSURANCE_TYPE_NAME',
          sorter: true,
          showOverflowTooltip: true
        },
        {
          title: '保险公司',
          dataIndex: 'INSURATION_SHORT_NAME',
          sorter: true,
          showOverflowTooltip: true
        },
        {
          title: '保险开始日期',
          dataIndex: 'INSURANCE_BEGIN_DATE',
          sorter: true
        },
        {
          title: '保险结束日期',
          dataIndex: 'INSURANCE_END_DATE',
          sorter: true
        },
        {
          title: '保单号',
          dataIndex: 'INSURANCE_BILL_NO',
          sorter: true,
          showOverflowTooltip: true
        },
        {
          title: '是否续保',
          dataIndex: 'RE_INSURE',
          sorter: true,
          render: props => {
            return <span>{this.createDictText(props.row.RE_INSURE, '1004')}</span>;
          }
        },
        {
          title: '应收金额',
          dataIndex: 'ACTUAL_EXPENDING',
          sorter: true
        },
        {
          title: '投保日期',
          dataIndex: 'INSURANCE_BUY_DATE',
          sorter: true
        }
      ];
    },
    closeDialog() {
      this.$emit('close', false);
    },
    async query() {
      let res = await queryHistory(this.VIN);
      if (res.resultCode === 200) {
        this.BaseTable.EXECUTE_INSERT(res.data);
      } else {
        return this.$notify.error({ title: '提示信息', message: '查询报错' });
      }
    }
  }
};
</script>
